<?php if (substr_count($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip')) ob_start("ob_gzhandler"); else ob_start(); ?>
<?php
session_cache_expire(10000);
ini_set('session.gc_maxlifetime', 10000 * 60);
@session_start();

error_reporting(0);

/**
 * set header with cache
 */

//if using Expires header,you have must disable Last-Modified or ETag
//only used both Last-Modified and ETag or both Expires and Cache-Control: max-age
header("Cache-Control: public, max-age=31536000");
header('Last-Modified: ' . gmdate("D, d M Y H:i:s") . ' GMT');
header("Expires: ".gmdate("D, d M Y H:i:s", time() + 31104000) . " GMT");
//header("Pragma: cache");
header("Content-Encoding: gzip");
include 'config.php';

$url = $_SERVER['REQUEST_URI'];
$url = preg_replace('/^\//', '', $url);

$aryURL = explode('/', $url);

//can sua lai $aryURL[0] khi tach
if (isset($aryURL[0])) {

    $controller = $aryURL[0];
}
//can sua lai $aryURL[1] khi tach
if (isset($aryURL[1])) {
    $adminController = $aryURL[1];
}

//$controller = 'admin';
if (get_magic_quotes_gpc()) {

    function stripslashes_deep($value) {
        
        $value = is_array($value) ? array_map('stripslashes_deep', $value) : stripslashes($value);

        return $value;
    }

    $_POST = array_map('stripslashes_deep', $_POST);
    $_GET = array_map('stripslashes_deep', $_GET);
    $_COOKIE = array_map('stripslashes_deep', $_COOKIE);
    $_REQUEST = array_map('stripslashes_deep', $_REQUEST);
}
//CONTROLLER
if ($controller && $controller == 'quanly') {
    include adminController_class;
    $objAdmin = new AdminControllers($aryConfigDB, $aryConfigs);
    $objAdmin->setParamsByUrl($aryURL);
    if ($adminController == false) {
        $objAdmin->def();
    } else {
        $objAdmin->$adminController();
    }
} else {
    include myController_class;
    $objController = new MyControllers($aryConfigDB, $aryConfigs);
    $objController->setParamsByUrl($aryURL);
    if ($controller == false) {
        $objController->def();
    } else {
        $objController->$controller();
    }
}
?>
